<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>How to use expression</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta name="generator" content="Doc-O-Matic" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <link rel="STYLESHEET" href="default.css" type="text/css" />

<script type="text/javascript" src="scripts.js"></script>
</head>
<body class="Element700" onload="onBodyLoadEx('frames.html', 'topic', 'How_to_use_expression.html');" onmousedown="onBodyMouseDown();">

<!-- Begin Popups -->

<!-- End Popups -->

<!-- Begin Page Header -->
<div class="Element710" id="areafixed">
<div class="Element94">
<em>You are here:</em> Using General SQL Parser &gt; <a href="How_to_use_expression.html" target="topic">How to use expression</a></div>
<div class="Element92">
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td width="50%">
<div class="Element2">
<a href="contents.html" target="tocidx"><img src="btn_globals_contents_midblue.gif" border="0" alt="Contents" title="Contents" onmouseover="switchImage(this, 'btn_globals_contents_midblue_hover.gif');" onmouseout="switchImage(this, 'btn_globals_contents_midblue.gif');"></a><a href="idx.html" target="tocidx"><img src="btn_globals_index_midblue.gif" border="0" alt="Index" title="Index" onmouseover="switchImage(this, 'btn_globals_index_midblue_hover.gif');" onmouseout="switchImage(this, 'btn_globals_index_midblue.gif');"></a><a href="index.html" target="topic"><img src="btn_globals_home_midblue.gif" border="0" alt="Home" title="Home" onmouseover="switchImage(this, 'btn_globals_home_midblue_hover.gif');" onmouseout="switchImage(this, 'btn_globals_home_midblue.gif');"></a></div>
</td><td width="50%">
<div class="Element90">
<a href="How_to_identify_DB_objects_in_your_sql.html" target="topic"><img src="btn_prev_midblue.gif" border="0" alt="Previous" title="Previous" onmouseover="switchImage(this, 'btn_prev_midblue_hover.gif');" onmouseout="switchImage(this, 'btn_prev_midblue.gif');"></a><img src="btn_up_d.gif" border="0" alt="Up" title="Up"><a href="Set_operation_in_select_statement.html" target="topic"><img src="btn_next_midblue.gif" border="0" alt="Next" title="Next" onmouseover="switchImage(this, 'btn_next_midblue_hover.gif');" onmouseout="switchImage(this, 'btn_next_midblue.gif');"></a></div>
</td></tr></table><div class="Element5">
How to use expression</div>
</div>
</div>

<!-- End Page Header -->

<!-- Begin Client Area -->
<div class="Element720" id="areascroll">
<div class="Element721">

<!-- Begin Page Content -->
<div class="Element58">
<a name="Description"></a><div class="Element11">
<div class="Element10">
<div class="Element15">
How to use expression</div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Structure of expression&nbsp;</p>
<p class="Element10">
Expression is widely used in the sql, such as in the where clause,having clause. The expression in General SQL Parser also known as condition or predicate. If you like to retrieve more info from the expression or like to modify the expression before rebuild your sql, then it's very important to know how expression is organized.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Expression is represented by the class <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a>, it is organized in a binary tree mode. So the expression : f1&gt;1 and f2=2 will be constructed something like this. </p><div class="Element13"><div class="Element12"><pre class="Element12">       and
        |
        |
    |-------|
    |       |
    &gt;       =
    |       |
 |-----|  |-----|
 |     |  |     |
f1     1  f2    2</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
So, from this diagram, you may know the basic elements of expression are operator and operand, here &quot;and&quot; is operator, &quot;f1&gt;1&quot; and &quot;f2=4&quot; are operand. In the <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a>, lexpr : TLz_node, rexpr : TLz_node are used to represent the left and right side operand separately if any. opname:<a href="TSourceToken.html" target="topic">TSourceToken</a> is the source token which represents the operator. Another key property of <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a> is oper : TLzOpType which give you a clearly type definition of this expression that supported by General SQL Parser.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Here is a list of all expressions type specified by oper:TLzOpType, along with their binary tree diagram.&nbsp;</p>
<p class="Element10">
Expr_Arithmetic&nbsp;</p>
<p class="Element10">
+ - / %&nbsp;</p>
<p class="Element10">
String Concatenation Operator&nbsp;</p>
<p class="Element10">
+ ||&nbsp;</p>
<p class="Element10">
Expr_Comparison&nbsp;</p>
<p class="Element10">
= &gt; &lt; &gt;= &lt;= &lt;&gt; != !&lt; !&gt;&nbsp;</p>
<p class="Element10">
Expr_Between Expr_NotBetween&nbsp;</p>
<p class="Element10">
Expr_In Expr_NotIn&nbsp;</p>
<p class="Element10">
Expr_Like Expr_NotLike&nbsp;</p>
<p class="Element10">
Expr_Exists&nbsp;</p>
<p class="Element10">
Expr_IsNull, Expr_IsNotNull&nbsp;</p>
<p class="Element10">
Logical operators&nbsp;</p>
<p class="Element10">
AND OR NOT&nbsp;</p>
<p class="Element10">
Expr_Unary&nbsp;</p>
<p class="Element10">
+ - ~&nbsp;</p>
<p class="Element10">
Expr_Assign&nbsp;</p>
<p class="Element10">
=&nbsp;</p>
<p class="Element10">
Bitwise Operators&nbsp;</p>
<p class="Element10">
&amp; | ^&nbsp;</p>
<p class="Element10">
Expr_Parenthesis&nbsp;</p>
<p class="Element10">
( )&nbsp;</p>
<p class="Element10">
Expr_Comma&nbsp;</p>
<p class="Element10">
,&nbsp;</p>
<p class="Element10">
Expr_subquery&nbsp;</p>
<p class="Element10">
Expr_FuncCall&nbsp;</p>
<p class="Element10">
Expr_Attr&nbsp;</p>
<p class="Element10">
Expr_Const&nbsp;</p>
<p class="Element10">
More expression types&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Arithmetic</div>
<p class="Element10">
+ Addition&nbsp;</p>
<p class="Element10">
- Subtraction&nbsp;</p>
<p class="Element10">
* Multiplication&nbsp;</p>
<p class="Element10">
/ Division&nbsp;</p>
<p class="Element10">
% Returns the integer remainder of a division. For example, 12 % 5 = 2&nbsp;</p>
<p class="Element10">
Sample: f1+2&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">     +
     |
 ----|----
 |       |
 |       |
f1       2</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: + f1 2&nbsp;</p>
<p class="Element10">
In-order: f1 + 2&nbsp;</p>
<p class="Element10">
Post-order: f1 2 +&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
String Concatenation Operator</div>
<p class="Element10">
+(sql server), represented by + of Expr_Arithmetic&nbsp;</p>
<p class="Element10">
|| (Oracle) Expr_ConcatenationOP&nbsp;</p>
<p class="Element10">
Sample: f1||f2&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">      ||
     |
 ----|----
 |       |
 |       |
f1       f2
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: || f1 f2&nbsp;</p>
<p class="Element10">
In-order: f1 || f2&nbsp;</p>
<p class="Element10">
Post-order: f1 f2 ||&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Comparison</div>
<p class="Element10">
= Equal to&nbsp;</p>
<p class="Element10">
&gt; Greater than&nbsp;</p>
<p class="Element10">
&lt; Less than&nbsp;</p>
<p class="Element10">
&gt;= Greater than or equal to&nbsp;</p>
<p class="Element10">
&lt;= Less than or equal to&nbsp;</p>
<p class="Element10">
&lt;&gt; Not equal to&nbsp;</p>
<p class="Element10">
!= Not equal to (not SQL-92 standard)&nbsp;</p>
<p class="Element10">
!&lt; Not less than (not SQL-92 standard)&nbsp;</p>
<p class="Element10">
!&gt; Not greater than (not SQL-92 standard)&nbsp;</p>
<p class="Element10">
Sample: f1&gt;2&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">     &gt;
     |
 ----|----
 |       |
 |       |
f1       2</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: &gt; f1 2&nbsp;</p>
<p class="Element10">
In-order: f1 &gt; 2&nbsp;</p>
<p class="Element10">
Post-order: f1 2 &gt;&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
ALL/ANY/SOME Compares a scalar value with a single-column set of values. So, if oper : TLzOpType is type of Expr_Comparison, then groupcompareType : TLzOPGroupCompareType maybe one of the followings TLzOPGroupCompareType = (gctNone,gctany,gctSome,gctAll);&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Between Expr_NotBetween</div>
<p class="Element10">
Sample: edate [NOT] BETWEEN '01-JAN-2004' AND '01-APR-2004'&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">  [NOT] BETWEEN
     |
 ----|----
 |       |
 |       |
edate   AND
         |
         |
     ----|---------
     |            |
     |            |
'01-JAN-2004'  '01-APR-2004'</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: between edate and(expr_betweento) '01-JAN-2004' '01-APR-2004'&nbsp;</p>
<p class="Element10">
In-order: edate between '01-JAN-2004' and(expr_betweento) '01-APR-2004'&nbsp;</p>
<p class="Element10">
Post-order: edate '01-JAN-2004' '01-APR-2004' and(expr_betweento) between&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_In Expr_NotIn</div>
<p class="Element10">
Sample: f1 in (1,2,3)&nbsp;</p>
<p class="Element10">
Diagram:&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element13"><div class="Element12"><pre class="Element12">     in
     |
 ----|----
 |       |
 |       |
 f1      ()
         |
     ---------
    |         |
    nil       ,
         -----------
        |          |
        1          ,
              -----------
              |          |
              2          3
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: in f1 () , 1 , 2 3&nbsp;</p>
<p class="Element10">
In-order: f1 in 1 , 2 , 3 ()&nbsp;</p>
<p class="Element10">
Post-order: f1 1 2 3 , , () in&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Like Expr_NotLike Expr_Escape</div>
<p class="Element10">
Sample: lname LIKE 'Fud%'&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">    LIKE
     |
 ----|----
 |       |
 |       |
lname  'Fud%'</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: like lname 'Fud%'&nbsp;</p>
<p class="Element10">
In-order: lname like 'Fud%'&nbsp;</p>
<p class="Element10">
Post-order: lname 'Fud%' like&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Expr: lname LIKE '\%\_\\%' ESCAPE '\'&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">    LIKE
     |
 ----|----
 |       |
 |       |
lname  ESCAPE
         |
         |
     ----|----
     |       |
     |       |
 '\%\_\\%'  '\'</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: like lname escape '\%\_\\%' '\'&nbsp;</p>
<p class="Element10">
In-order: lname like '\%\_\\%' escape '\'&nbsp;</p>
<p class="Element10">
Post-order: lname '\%\_\\%' '\' escape like&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Exists</div>
<p class="Element10">
Sample: exists (select f1 from t1)&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">   exists
     |
 ----|----
 |       |
 |       |
nil   (select f1 from t1)</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
This is a leaf node of expression, so no more iterate.&nbsp;</p>
<p class="Element10">
you can check right node of this tree to find more info about subquery.&nbsp;</p>
<p class="Element10">
right node of this expression cab be casted to <a href="TSelectSqlStatement.html" target="topic">TSelectSqlStatement</a>&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_IsNull, Expr_IsNotNull</div>
<p class="Element10">
Sample: f1 is null&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">    is null
     |
 ----|----
 |       |
 |       |
f1      nil</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: Expr_IsNull f1&nbsp;</p>
<p class="Element10">
In-order: f1 Expr_IsNull&nbsp;</p>
<p class="Element10">
Post-order: f1 Expr_IsNull&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Logical operators:</div>
<p class="Element10">
Expr_AND&nbsp;</p>
<p class="Element10">
Expr_OR&nbsp;</p>
<p class="Element10">
Expr_NOT&nbsp;</p>
<p class="Element10">
Sample: f1&gt;1 and f2=2&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">    and
     |
 ----|----
 |       |
 |       |
f1&gt;1    f2=2</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: and &gt; f1 1 = f2 2&nbsp;</p>
<p class="Element10">
In-order: f1 &gt; 1 and f2 = 2&nbsp;</p>
<p class="Element10">
Post-order: f1 1 &gt; f2 2 = and&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Sample: not f1&gt;1&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">    not
     |
 ----|----
 |       |
 |       |
nil     f1&gt;1</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Note: In this expression, left operand is null.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: not &gt; f1 1&nbsp;</p>
<p class="Element10">
In-order: not f1 &gt; 1&nbsp;</p>
<p class="Element10">
Post-order: f1 1 &gt; not&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Unary</div>
<p class="Element10">
+ (Positive) Numeric value is positive.&nbsp;</p>
<p class="Element10">
- (Negative) Numeric value is negative.&nbsp;</p>
<p class="Element10">
~ (Bitwise NOT) Returns the ones complement of the number.&nbsp;</p>
<p class="Element10">
Sample: -1&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">     -
     |
 ----|----
 |       |
 |       |
nil      1
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Note: In this expression, left operand is null.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: - 1&nbsp;</p>
<p class="Element10">
In-order: - 1&nbsp;</p>
<p class="Element10">
Post-order: 1 -&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Assign =</div>
<p class="Element10">
Sample: f1 = 2&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">     =
     |
 ----|----
 |       |
 |       |
f1       2
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: = f1 2&nbsp;</p>
<p class="Element10">
In-order: f1 = 2&nbsp;</p>
<p class="Element10">
Post-order: f1 2 =&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Assignment operator = maybe mishandled by Expr_Comparison equal operator =, or vice versa.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
= in following clauses must be Assignment operator&nbsp;</p>
<p class="Element10">
SQL Server:&nbsp;</p>
<p class="Element10">
select list in select statement&nbsp;</p>
<p class="Element10">
set clause in update statement&nbsp;</p>
<p class="Element10">
opt_output_clause&nbsp;</p>
<p class="Element10">
index_params in create index statement&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Bitwise Operators</div>
<p class="Element10">
&amp; (Bitwise AND) Bitwise AND (two operands).&nbsp;</p>
<p class="Element10">
| (Bitwise OR) Bitwise OR (two operands).&nbsp;</p>
<p class="Element10">
^ (Bitwise Exclusive OR) Bitwise exclusive OR (two operands).&nbsp;</p>
<p class="Element10">
Sample: f1 &amp; 2&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">     &amp;
     |
 ----|----
 |       |
 |       |
f1       2
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: &amp; f1 2&nbsp;</p>
<p class="Element10">
In-order: f1 &amp; 2&nbsp;</p>
<p class="Element10">
Post-order: f1 2 &amp;&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Parenthesis</div>
<p class="Element10">
() The parentheses are grouping operators that make sure that all the operators in the expression within the parentheses are evaluated before the resulting expression is combined with another.&nbsp;</p>
<p class="Element10">
Sample: (1,2,3)&nbsp;</p>
<p class="Element10">
Diagram:&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element13"><div class="Element12"><pre class="Element12">      ()
      |
  ---------
 |         |
 nil       ,
      -----------
     |          |
     1          ,
          -----------
         |          |
         2          3
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: () , 1 , 2 3&nbsp;</p>
<p class="Element10">
In-order: 1 , 2 , 3 ()&nbsp;</p>
<p class="Element10">
Post-order: 1 2 3 , , ()&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Comma</div>
<p class="Element10">
This expression use comma(,) to connect left and right node.&nbsp;</p>
<p class="Element10">
Sample: (1,2,3)&nbsp;</p>
<p class="Element10">
Diagram:&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element13"><div class="Element12"><pre class="Element12">      ()
      |
  ---------
 |         |
 nil       ,
      -----------
     |          |
     1          ,
          -----------
         |          |
         2          3
</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Visit binary parse tree of this expression:&nbsp;</p>
<p class="Element10">
Pre-order: () , 1 , 2 3&nbsp;</p>
<p class="Element10">
In-order: 1 , 2 , 3 ()&nbsp;</p>
<p class="Element10">
Post-order: 1 2 3 , , ()&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_subquery</div>
<p class="Element10">
Left node of this expression is a parse tree node with type of <a href="TSelectSqlStatement.html" target="topic">TSelectSqlStatement</a>. and right node is null.&nbsp;</p>
<p class="Element10">
This is a leaf node of a binary tree that represents a expression.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_FuncCall</div>
<p class="Element10">
Left node of this expression is a parse tree node with type of <a href="TLz_FuncCall.html" target="topic">TLz_FuncCall</a>. and right node is null.&nbsp;</p>
<p class="Element10">
This is a leaf node of a binary tree that represents a expression.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Attr</div>
<p class="Element10">
Left node of this expression is a parse tree node with type of <a href="TLz_Attr.html" target="topic">TLz_Attr</a>. and right node is null.&nbsp;</p>
<p class="Element10">
This is a leaf node of a binary tree that represents a expression.&nbsp;</p>
<p class="Element10">
Expression of type Expr_Attr is often used to represent a database object. such as empno in empno &gt; 1, scott.empno in scott.empno &gt; 1.&nbsp;</p>
<p class="Element10">
You can check left node of this expression which is type of <a href="TLz_Attr.html" target="topic">TLz_Attr</a> for more detail info.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Const</div>
<p class="Element10">
Left node of this expression is a parse tree node with type of <a href="TLz_Const.html" target="topic">TLz_Const</a>. and right node is null.&nbsp;</p>
<p class="Element10">
This is a leaf node of a binary tree that represents a expression.&nbsp;</p>
<p class="Element10">
Expression of type Expr_Const is used to represent the const in an expression such as integer, float and single quote string.&nbsp;</p>
<p class="Element10">
1000 in expr: sal &gt; 1000, 'John' in expr: empname like 'John'.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Case</div>
<p class="Element10">
Case function.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Rollup</div>
<p class="Element10">
Rollup function.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Cube</div>
<p class="Element10">
Cube function.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_GroupingSets</div>
<p class="Element10">
grouping sets.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Ident(NOT AVAILABLE after ver1.9, use expr_attr instead)</div>
<p class="Element10">
left node of this expression is a parse tree node with type of Tlz_Ident. and right node is null.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Leftjoin</div>
<p class="Element10">
Old left join syntax of SQL Server, t1.f1 *= t2.f2 in where clause&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Rightjoin</div>
<p class="Element10">
Old right join syntax of SQL Server, t1.f1 =* t2.f2 in where clause&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_OuterJoin</div>
<p class="Element10">
Old join sytle of oracle, expr1(+)&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Cursor</div>
<p class="Element10">
cursor (select f1 from t1)&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_AtTimeZone</div>
<p class="Element10">
expr1 at time zone expr2&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_DatetimeAtLocal</div>
<p class="Element10">
Oracle: expr at local&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_DayToSecond</div>
<p class="Element10">
expr1 day to second&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_YearToMonth</div>
<p class="Element10">
expr1 year to month&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_func_exprs</div>
<p class="Element10">
function expression in pl/sql.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Plsql_sql_condition</div>
<p class="Element10">
condition expression in pl/sql.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_DoubleStar</div>
<p class="Element10">
expression in pl/sql.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Mssql_timestamp_literal</div>
<p class="Element10">
timestamp literal of SQL Server.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_LabelDuration</div>
<p class="Element10">
DB2 specific&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_DeterminedBy</div>
<p class="Element10">
DB2 specific.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_isoftype</div>
<p class="Element10">
&nbsp;</p>
<div class="Element15">
Expr_OP</div>
<p class="Element10">
Unknown expression, check opname:<a href="TSourceToken.html" target="topic">TSourceToken</a> for operator, left and right node for child node.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Other</div>
<p class="Element10">
Unknown expression, check opname:<a href="TSourceToken.html" target="topic">TSourceToken</a> for operator, left and right node for child node.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_NotSupported</div>
<p class="Element10">
Unknown expression, check opname:<a href="TSourceToken.html" target="topic">TSourceToken</a> for operator, left and right node for child node.&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Expr_Unknown</div>
<p class="Element10">
Unknown expression, check opname:<a href="TSourceToken.html" target="topic">TSourceToken</a> for operator, left and right node for child node.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Leaf and non-leaf node of expression binary tree&nbsp;</p>
<p class="Element10">
Leaf node has no child node which type is <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a>. In other words, lexpr, rexpr of leaf node is not the type of <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a>.&nbsp;</p>
<p class="Element10">
non-leaf node has at least one child node that is type of <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a>.&nbsp;</p>
<p class="Element10">
Expression with expr type of Expr_subquery, Expr_FuncCall, Expr_Case, Expr_Attr, Expr_Const, Expr_Cursor is leaf node.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Visit expression binary tree</div>
<p class="Element10">
You can visit the expression binary tree in pre-order,in-order and post-order by using&nbsp;</p>
<p class="Element10">
PreOrderTraverse(pVisit : <a href="TLzExprVisitFunc.html" target="topic">TLzExprVisitFunc</a>)&nbsp;</p>
<p class="Element10">
procedure InOrderTraverse(pVisit : <a href="TLzExprVisitFunc.html" target="topic">TLzExprVisitFunc</a>);&nbsp;</p>
<p class="Element10">
procedure PostOrderTraverse(pVisit : <a href="TLzExprVisitFunc.html" target="topic">TLzExprVisitFunc</a>);&nbsp;</p>
<p class="Element10">
pVisit : <a href="TLzExprVisitFunc.html" target="topic">TLzExprVisitFunc</a> is a user defined function to process the tree node.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Take f1+f2&gt;3 for example:&nbsp;</p>
<p class="Element10">
pre-order: &gt; + f1 f2 3&nbsp;</p>
<p class="Element10">
in-order: f1 + f2 &gt; 3&nbsp;</p>
<p class="Element10">
post-order: f1 f2 + 3 &gt;&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element15">
Create expression manually</div>
<p class="Element10">
Usually, expression is created by parser after process the sql query. However, you can create expression directly by using another constructor of <a href="TLzCustomExpression.html" target="topic">TLzCustomExpression</a> by specifing the AOwner: TComponent; pDBVendor : TDBVendor; pStr : LzString.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Here is an example shows how to use a manual created expression together with a parser created one, and form a new expression.&nbsp;</p>
<p class="Element10">
Expression created by parser: f1+f2&gt;3&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram:&nbsp;</p>
<p class="Element10">
&nbsp;</p><div class="Element13"><div class="Element12"><pre class="Element12">          &gt;
          |
      ----|-----
      |        |
      |        |
      +        3
      |
  ----|-----
  |        |
  |        |
  f1       f2</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Create a expression f3-f4, and replace left node of f1+f2&gt;3, then&nbsp;</p>
<p class="Element10">
The expression will be like this : f1+f2&gt; f3-f4&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Diagram: </p><div class="Element13"><div class="Element12"><pre class="Element12">
          &gt;
          |
      ----|--------
      |           |
      |           |
      +           -
      |           |
  ----|-----    --|---
  |        |   |     |
  |        |   |     |
  f1       f2  f3    f4</pre></div></div>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<div class="Element15">
Modify and rebuild expression</div>
<p class="Element10">
Modify expression, especially modify predicate in where clause is a feature requested by lots of users. Although it's possbile, before ver1.5, It's a tough task to modify the expression . Now, we add two features to expression which make it very easy to manipulate expression.&nbsp;</p>
<p class="Element10">
1.Create your own visitor to visit expression in pre-order/in-order/post-order.&nbsp;</p>
<p class="Element10">
2. Rebuild expression automatically after you set different parts of the expression, and still make expression valid in the predicate. so, if you remove f2 from this expression: f1&gt;1 and f2&lt;10, it will become to f1&gt;1 which is more reasonable than f1&gt;1 and &lt;10&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
The way to modify an expression is as easy as this: expr.AsText = NewValue&nbsp;</p>
<p class="Element10">
Note: If you want to remove expression, just assign a space (not an empty string) to it like this: expr.AsText = ' '&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Check <a href="http://www.sqlparser.com/dl/samples/visitexpression.zip">http://www.sqlparser.com/dl/samples/visitexpression.zip</a> to find out more detail info about how to use expression in your sql.</p></div>
</div>
</div>
<!-- End Page Content -->

<!-- Begin Page Footer -->
<div class="Element93">
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td width="100%">
<div class="Element3">
Gudu software http://www.sqlparser.com</div>
</td></tr><tr><td width="100%">
<div class="Element97">
Send <a href="#" onclick="sendFeedback('info@sqlparser.com', 'Documentation Feedback', 'Project: General SQL Parser Help file%0ATopic ID: How to use expression%0ATitle: How to use expression');">comments</a> about this topic.</div>
</td></tr></table></div>

<!-- End Page Footer -->
</div>
</div>

<!-- End Client Area -->
</body></html>